package com.jwcao.common.cast.operation.callback;

import com.jwcao.common.cast.annotation.factory.CastCallBackFactory;
import com.jwcao.common.scan.object.ScanClass;
import java.lang.reflect.Method;

/**
 * name: CallBackOperationFactory description: TODO
 *
 * @author caojingwei date: 2023/3/25 13:01
 */
public class CallBackOperationFactory {

    public static FromCallBackOperation getFrom(String id, ScanClass targetClass) {
        Method method = CastCallBackFactory.getFrom(id, targetClass);
        if (method != null) {
            return new FromCallBackOperation(targetClass, method.getName());
        }

        return null;
    }

    public static ToCallBackOperation getTo(String id, ScanClass sourceClass) {
        Method method = CastCallBackFactory.getTo(id, sourceClass);
        if (method != null) {
            return new ToCallBackOperation(sourceClass, method.getName());
        }
        return null;
    }

}
